# Contributor: Frederic Wang <fred.wang@free.fr>

_realname=mock
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python2-${_realname}" "${MINGW_PACKAGE_PREFIX}-python3-${_realname}")
pkgver=2.0.0
pkgrel=2
pkgdesc='Rolling backport of unittest.mock for all Pythons (mingw-w64)'
arch=('any')
url='https://github.com/testing-cabal/mock'
license=('BSD')
makedepends=("${MINGW_PACKAGE_PREFIX}-python3"
             "${MINGW_PACKAGE_PREFIX}-python2"
             "${MINGW_PACKAGE_PREFIX}-python3-six"
             "${MINGW_PACKAGE_PREFIX}-python2-six"
             "${MINGW_PACKAGE_PREFIX}-python3-funcsigs"
             "${MINGW_PACKAGE_PREFIX}-python2-funcsigs"
             "${MINGW_PACKAGE_PREFIX}-python3-pbr"
             "${MINGW_PACKAGE_PREFIX}-python2-pbr")
source=("https://pypi.python.org/packages/source/m/${_realname}/${_realname}-${pkgver}.tar.gz")
sha256sums=('b158b6df76edd239b8208d481dc46b6afd45a846b7812ff0ce58971cf5bc8bba')
noextract=(${_realname}-${pkgver}.tar.gz)

prepare() {
  [[ -d ${srcdir}/${_realname}-${pkgver} ]] && rm -rf ${srcdir}/${_realname}-${pkgver}
  tar -xzf ${srcdir}/${_realname}-${pkgver}.tar.gz -C ${srcdir} || true

  cd "${srcdir}"
  cp -r ${_realname}-${pkgver} python2-build
  cp -r ${_realname}-${pkgver} python3-build
}

package_python3-mock() {
  depends=("${MINGW_PACKAGE_PREFIX}-python3")

  cd ${srcdir}/python3-build
  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
  ${MINGW_PREFIX}/bin/python3 setup.py install --prefix=${MINGW_PREFIX} \
    --root="${pkgdir}" --optimize=1

  install -Dm644 LICENSE.txt "${pkgdir}${MINGW_PREFIX}/share/licenses/python3-${_realname}/LICENSE"
}

package_python2-mock() {
  depends=("${MINGW_PACKAGE_PREFIX}-python2")

  cd ${srcdir}/python2-build
  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
  ${MINGW_PREFIX}/bin/python2 setup.py install --prefix=${MINGW_PREFIX} \
    --root="${pkgdir}" --optimize=1

  install -Dm644 LICENSE.txt "${pkgdir}${MINGW_PREFIX}/share/licenses/python2-${_realname}/LICENSE"
}

package_mingw-w64-i686-python2-mock() {
  package_python2-mock
}

package_mingw-w64-i686-python3-mock() {
  package_python3-mock
}

package_mingw-w64-x86_64-python2-mock() {
  package_python2-mock
}

package_mingw-w64-x86_64-python3-mock() {
  package_python3-mock
}
